package com.yjd.bi.fund.dao.impl;

import com.yjd.bi.fund.dao.IBiFundsStatisticsDao;
import com.yjd.bi.fund.model.BiFundsStatisticsModel;
import com.yjd.comm.base.dao.impl.BaseDaoImpl;
import com.yjd.comm.util.FrameUtil;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * <b>description</b>：资金量记录数据访问层 <br>
 * <b>time</b>：2016-04-14 15:09:59 <br>
 * <b>author</b>： chenpengfei@yijeidai.com
 */
@Component("biFundsStatisticsDao")
public class BiFundsStatisticsDaoImpl extends BaseDaoImpl implements IBiFundsStatisticsDao {

	private static final String SQLMAPNAMESPACE = BiFundsStatisticsModel.class.getName();
	private static final String PKNAME = "id";

	@Override
	public String getPrimaryKeyName() {
		return PKNAME;
	}

	@Override
	public String getSqlmapNamespace() {
		return SQLMAPNAMESPACE;
	}
	
	@Override
	public double getFundsSum(Map<String, Object> paramMap, boolean b) {
		Object myObject = this.getSqlMap(b).queryForObject(this.getStatement("fundsSum"),paramMap);
		if (myObject != null) {
			return Double.parseDouble(myObject.toString());
		}
		return 0.00D;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public BiFundsStatisticsModel getSummaryModel(Map paramMap, boolean write)
			throws Exception {
		if (paramMap == null) {
			paramMap = FrameUtil.newHashMap();
		}
		if (!paramMap.containsKey("rowstartindex")) {
			paramMap.put("rowstartindex", 0);
			paramMap.put("rowendindex", 1);
		}
		List<BiFundsStatisticsModel> list = this.getSqlMap(write).queryForList(
				this.getStatement("getSummaryModel"), paramMap);
		return list.size() >= 1 ? list.get(0) : null;
	}

	@Override
	public Double getLckSummary(Map<String, Object> paramMap, boolean b) {
		Object myObject = this.getSqlMap(b).queryForObject(this.getStatement("getLckSummary"),paramMap);
		if (myObject != null) {
			return Double.parseDouble(myObject.toString());
		}
		return 0.00D;
	}

	@Override
	public double getfundsSumAllAvailable(Map<String, Object> paramMap, boolean b) {
		Object myObject = this.getSqlMap(b).queryForObject(this.getStatement("fundsSumAllAvailable"), paramMap);
		if (myObject != null) {
			return Double.parseDouble(myObject.toString());
		}
		return 0.00D;
	}

	@Override
	public double getfundsSumAvailable(Map<String, Object> paramMap, boolean b) {
		Object myObject = this.getSqlMap(b).queryForObject(this.getStatement("fundsSumAvailable"), paramMap);
		if (myObject != null) {
			return Double.parseDouble(myObject.toString());
		}
		return 0.00D;
	}
}
